{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>类目列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->
            <div class="row">
                <div class="col-sm-12">
                    <div  class="col-sm-2" style="width: 100px">
                        <div class="input-group" >
                            <a href="{:url('add_Knowledge')}"><button class="btn btn-primary" type="button">添加类目</button></a>
                        </div>
                    </div>
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                        <tr class="long-tr">
                            <th>ID</th>
                            <th>类目名称</th>
                            <th width="5%">图片</th>
                            <th width="15%">说明</th>
                            <th width="15%">添加时间</th>
                            <th width="20%">操作</th>
                        </tr>
                        </thead>
                        <tbody id="article_list">
                        {foreach name="lists" item="vo"}
                        <tr class="long-td">
                            <td>{$vo.id}</td>
                            <td>{$vo.name}</td>
                            <td><img src="{$vo.logo}" style="height: 30px" onerror="this.src='/static/admin/images/no_img.jpg'"/></td>
                            <td>{$vo.remark}</td>
                            <td>{$vo.create_time|date="Y-m-d H:i:s",###}</td>
                            <td>
                                <a href="{:url('children',['id'=>$vo.id])}" class="btn btn-info btn-xs">
                                    <i class="fa fa-paste"></i> 子类</a>&nbsp;
                                <a href="{:url('edit_knowledge',['id'=>$vo.id])}" class="btn btn-primary btn-xs">
                                    <i class="fa fa-paste"></i> 编辑</a>&nbsp;&nbsp;
                                <a href="javascript:;" onclick="del_knowledge({$vo.id})" class="btn btn-danger btn-xs">
                                    <i class="fa fa-trash-o"></i> 删除</a>
                            </td>
                        </tr>
                        {/foreach}
                        {if empty($vo)}
                        <td colspan="6" class="text-center"> aOh! 暂时还没有数据哦~  </td>
                        {/if}
                        </tbody>
                    </table>
                </div>
                <!-- 分页 -->
                <div id="Pages"> {$page} </div>
            </div>
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
{include file="public/footer" /}


<script type="text/javascript">
    function del_knowledge(id){
        layer.confirm('确认删除此数据?', {icon: 3, title:'提示'}, function(index){
            //do something
            $.getJSON("{:url('del_knowledge')}", {'id' : id}, function(res){
                if(res.code == 1){
                    layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(){
                        window.location.href="{:url('knowledge/index')}";
                    });
                }else{
                    layer.msg(res.msg,{icon:0,time:1500,shade: 0.1});
                }
            });

            layer.close(index);
        })

    }
</script>
</body>
</html>